package com.icez.banner_view

import android.util.Log
import android.view.View
import androidx.viewpager2.widget.ViewPager2
import kotlin.math.abs

class AlphaScalePageTransformer(val mAlphaScaleRatio:Float) : ViewPager2.PageTransformer {

    override fun transformPage(page: View, position: Float) {
        //处理左边的
        if (position <= 0) {
            page.alpha =
                0.5f + 0.5f * (1 + position)
        } else { // 处理右边
            page.alpha =
                0.5f + 0.5f * (1 - position)
        }
        val scale = mAlphaScaleRatio.coerceAtLeast(1 - abs(position))
        page.scaleX = scale
        page.scaleY = scale





    }
}